<?php

/*
 * Copyright 2008 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#namespace tehframework\annotations;

#use tehframework\testing\phpunit\TestCase;

require_once 'test/testHelper.php';

class AnnotationDefinitionTest extends TestCase
{
	function testToStringReturnsStringRepresentatingOfObject()
	{
		$this->assertNotSame('', (string)new AnnotationDefinition(
			'Fake',
			'MoreFake',
			'dummy',
			array(1, 2, 3),
			array('one' => 1, 'two' => 2, 'three' => 3)
		));
	}
	
	function testConstructThrowsExceptionIfNameIsEmpty()
	{
		$this->setExpectedException('InvalidArgumentException');
		
		new AnnotationDefinition('');
	}
	
	function testConstructSetsNameProperty()
	{
		$val = 'Fake';
		
		$def = new AnnotationDefinition($val);
		
		$this->assertSame($val, $def->name);
	}
	
	function testConstructSetsTypeProperty()
	{
		$val = 'MoreFake';
		
		$def = new AnnotationDefinition('Fake', $val);
		
		$this->assertSame($val, $def->type);
	}
	
	function testConstructSetsParameterProperty()
	{
		$val = 'dummy';
		
		$def = new AnnotationDefinition('Fake', null, $val);
		
		$this->assertSame($val, $def->parameter);
	}
	
	function testConstructSetsArgumentsProperty()
	{
		$val = array(1, 2, 3);
		
		$def = new AnnotationDefinition('Fake', null, null, $val);
		
		$this->assertSame($val, $def->arguments);
	}
	
	function testConstructSetsPropertiesProperty()
	{
		$val = array('one' => 1, 'two' => 2, 'three' => 3);
		
		$def = new AnnotationDefinition('Fake', null, null, array(), $val);
		
		$this->assertSame($val, $def->properties);
	}
}